<?php
namespace app\api\controller;

use app\BaseController;
use app\common\tools\Haikang as HaikangTools;

class Haikang extends BaseController
{
    /**
     * 查询消防设备列表
     *
     * @return void
     * @author sunhaoqiang(shqdev@163.com)
     * @time 2020-01-18 15:12
     */
    public function list()
    {
        $key = '27076561';
        $secret = 'puOMuVbZfbNu0LDo1p5x';
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/irds/v2/resource/resourcesByParams';
        $haikangTools = new HaikangTools($host, $api);

        $data = $haikangTools->get_resource_list();
        return json($data);
    }

    /**
     * 查询消防传感器列表 fireSensor
     *
     * @return void
     * @author sunhaoqiang(shqdev@163.com)
     * @time 2020-01-18 15:12
     */
    public function sensor()
    {
        $key = '27076561';
        $secret = 'puOMuVbZfbNu0LDo1p5x';
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/irds/v2/resource/resourcesByParams';
        $haikangTools = new HaikangTools($host, $api);

        $postData = [
            'pageNo' => (int)1,
            'pageSize' => (int)1000,
            'resourceType' => 'fireSensor'
        ];
        $data = $haikangTools->get_list($postData);
        return json($data);
    }

    /**
     * 查询消防监测数据
     *
     * @return void
     * @author sunhaoqiang(shqdev@163.com)
     * @time 2020-01-18 15:25
     */
    public function minitor()
    {
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/fpms/v1/minitor/data/search';
        // /api/fpnms/v1/device/status/search
        $haikangTools = new HaikangTools($host, $api);

        $postData = [
            'pageNo' => (int)1,
            'includeDown' => 1,
            'regionIndexCode' => "root000000"
        ];
        $data = $haikangTools->get_list($postData);
        return json($data);
    }

    /**
     * 获取编码设备列表(相机列表)
     *
     * @return void
     * @author sunhaoqiang(shqdev@163.com)
     * @time 2020-01-18 17:34
     */
    public function vedio()
    {
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/resource/v1/encodeDevice/get';
        // /api/fpnms/v1/device/status/search
        $haikangTools = new HaikangTools($host, $api);

        $postData = [
            'pageNo' => (int)1,
            'pageSize' => (int)1000,
            // 'includeDown' => 1,
            // 'regionIndexCode' => "de21f8852c3e4d3e8e02825c4603fbd2"
        ];
        $data = $haikangTools->get_list($postData);
        return json($data);
    }


    /**
     * 查询消防设备部件状态
     *
     * @return void
     * @author sunhaoqiang(shqdev@163.com)
     * @time 2020-01-20 15:51
     */
    public function status()
    {
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/fpnms/v1/device/status/search';
        // /api/fpnms/v1/device/status/search
        $haikangTools = new HaikangTools($host, $api);

        $postData = [
            'pageNo' => (int)1,
            // 'pageSize' => (int)1000,
            'includeSubNode' => 1,
            'regionIndexCode' => "root000000"
        ];
        $data = $haikangTools->get_list($postData);
        return json($data);
    }

    public function data()
    {
        $host = 'https://222.174.187.242:1443';
        $api = '/artemis/api/fpms/v1/minitor/data/search';
        // /api/fpnms/v1/device/status/search
        $haikangTools = new HaikangTools($host, $api);

        $postData = [
            'pageNo' => (int)1,
            'includeDown' => 1,
            'regionIndexCode' => "root000000"
        ];
        $data = $haikangTools->get_list($postData);
        return json($data);
    }

    public function del()
    {
        return 'Record,del';
    }
}
